﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace HD_CoCaNgua
{
    public partial class MyGame : Form
    {
        // Game manager: define all contents in game
        

        public MyGame()
        {
            InitializeComponent();
        }

        private void MyGame_Load(object sender, EventArgs e)
        {
            // Set full screen
            this.WindowState = FormWindowState.Maximized;

            // Load all contents
            //
            //------------------------------------
            //

            //Show main menu game first.
        }

        // Override OnPaint function
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            // Create off screen graphic for double buffer drawing.
            Bitmap bmpOff = new Bitmap(ClientRectangle.Width, ClientRectangle.Height);
            Graphics gOff = Graphics.FromImage(bmpOff);
            
            // Draw all object on gOff graphic
            ///
            //-------------draw here-----------
            ///

            // Copy off screen image onto on screen
            Graphics gOn = this.CreateGraphics();
            gOn.DrawImage(bmpOff, 0, 0, ClientRectangle, GraphicsUnit.Pixel);
            

            // Destroy on screen graphic
            gOn.Dispose();

//            base.OnPaint(e);
        }

        // Override OnPaintBackground function
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            // Do nothing.
        }

        // Override OnKeyDown function
        protected override void OnKeyDown(KeyEventArgs e)
        {
            switch (e.KeyData)
            {
                case Keys.Left:
                    //
                    ProcessKeyLeft();
                    break;

                case Keys.Right:
                    //
                    ProcessKeyRight();
                    break;
                case Keys.Up:
                    //
                    ProcessKeyUp();
                    break;
                case Keys.Down:
                    //
                    ProcessKeyDown();
                    break;
                
                default:
                    break;
            }


            base.OnKeyDown(e);
        }

        // Process when left key is pressed.
        private void ProcessKeyLeft()
        {
            return;
        }

        // Process when right key is pressed.
        private void ProcessKeyRight()
        {
            return;
        }


        // Process when up key is pressed.
        private void ProcessKeyUp()
        {
            return;
        }


        // Process when down key is pressed.
        private void ProcessKeyDown()
        {
            return;
        }

        
        
    }
}